function delComment(delRowId){
    var $confirm = $('#my-comment-confirm');
    var confirm = $confirm.data('amui.modal');
    var onConfirm = function() {
        console.log(delRowId)
        $.post("/smtool_project/wxapp/morningconference/delComment",{rowId:delRowId},
            function (data, status) {
                if(data.code == 200)
                    $("#"+delRowId).remove();
            });
    }
    var onCancel = function() {

    }
    if (confirm) {
        confirm.options.onConfirm =  onConfirm;
        confirm.options.onCancel =  onCancel;
        confirm.toggle(this);
    } else {
        $confirm.modal({
            relatedElement: this,
            onConfirm: onConfirm,
            onCancel: onCancel
        });
    }
    // $('#my-comment-confirm').modal({
    //     relatedTarget: this,
    //     onConfirm: function (options) {
    //         var $link = $(this).prev('div');console.log($link)
    //         $.post("/smtool_project/wxapp/morningconference/delComment",params,
    //             function (data, status) {
    //                 if(data.code == 200)
    //                     $("#"+delRowId).remove();
    //             });
    //     },
    //     // closeOnConfirm: false,
    //     onCancel: function () {
    //     }
    // });
}
function editComment(rowId){

}
function setComment(comment,usrImg){
    var usrImg = usrImg || '/images/icon/user.png';
    console.log(comment.rowId)
    var comment = '<li class="am-comment" id="'+comment.rowId+'"><article class="am-comment"><a href="#link-to-user-home">' +
        '<img src="'+usrImg+'" alt="" class="am-comment-avatar" width="48" height="48"/></a>' +
    '<div class="am-comment-main"><header class="am-comment-hd"><div class="am-comment-meta">' +
    '<a href="#link-to-user" class="am-comment-author">'+comment.name +'</a> 评论于 ' +
    '<time datetime="" title="">'+comment.createAt+'</a></time></div>' +
    '<div class="am-comment-actions" style="font-size:18px">' +
            // '<i class="am-icon-pencil"></i></a>' +
    ' <a href="#" onClick = "delComment(\''+comment.rowId+'\')">' +
    '<i class="am-icon-close"></i></a></div>'+
    '</header>' +
    '<div class="am-comment-bd">'+comment.context+'</div></div></article></li>';
    return comment;
}

function openComment(rowId,url,usrImg,type){
    if(!url)return;
        $('#my-prompt').modal({
            relatedTarget: this,
            onConfirm: function(e) {
                var content = $.trim(e.data);
                if(content.length>0) {
                    $.post(url, {
                            mconference: rowId,
                            type: type,
                            context: content
                        },
                        function (data, status) {
                            if (data && data.comment.rowId) {
                                var commentInfo = setComment(data.comment,usrImg);
                                $(".am-comments-list").prepend(commentInfo);

                            }
                        });
                }
            },
            onCancel: function(e) {
            }
        });

}